package com.wolf.controller;

import com.wolf.pojo.Wl_commodity_brand;
import com.wolf.pojo.Wl_commodity_brand_tag_rel;
import com.wolf.service.Wl_commodity_brand_tag_relService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import com.wolf.util.execl;
import com.wolf.util.Math;

@Controller
@ComponentScan
public class Wl_commodity_brand_tag_relController {

    @Autowired
    Wl_commodity_brand_tag_relService wl_commodity_brand_tag_relService;

    /***
     * 新增品牌信息后，对应新增中间表记录
     * @param request
     * @return
     */
    @RequestMapping("Wl_commodity_brand_tag_rel_insertTagRelWithBrand")
    public String insertTagRelWithBrand(HttpServletRequest request){

        Wl_commodity_brand wl_commodity_brand= (Wl_commodity_brand)request.getSession().getAttribute("wl_commodity_brand");
        String brandTagId= (String)request.getSession().getAttribute("brandTagId");

        Wl_commodity_brand_tag_rel wl_commodity_brand_tag_rel=new Wl_commodity_brand_tag_rel();
        wl_commodity_brand_tag_rel.setId(Math.random());
        wl_commodity_brand_tag_rel.setBrandid(wl_commodity_brand.getId());
        wl_commodity_brand_tag_rel.setBrandtagid(brandTagId);
        wl_commodity_brand_tag_rel.setCreatetime(new Date());
        wl_commodity_brand_tag_rel.setStatus(1);
        int result=this.wl_commodity_brand_tag_relService.insertSelective(wl_commodity_brand_tag_rel);

        System.out.println(result);

        return "redirect:wl_commodity_brand_getAll";
    }
}
